package com.hnkywl.sts.service.report;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.hnkywl.sts.dao.report.XshtlyzkDao;
import net.ruixin.orm.hibernate.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 销售合同履约状况
 * Created by ccr on 2014/6/24.
 */
@Service
public class XshtlyzkService {
    private XshtlyzkDao xshtlyzkDao;

    public String xshtList(String cght,String xsht,String xsdh,String wzbm,Long khId,int pageNo,int pageSize) {
        Page<Map> page = xshtlyzkDao.xshtList(cght, xsht,xsdh, wzbm, khId, pageNo, pageSize);
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        String json = gson.toJson(page.getResult());
        return "{\"total\":" + page.getTotalCount() + ",\"rows\":" + json + "}";
    }
    public String xshtlyzkDetailList(Long htId) {
        Map<String,List> map = xshtlyzkDao.xshtlyzkDetailList(htId);
        return new Gson().toJson(map);
    }

    @Autowired
    public void setXshtlyzkDao(XshtlyzkDao xshtlyzkDao) {
        this.xshtlyzkDao = xshtlyzkDao;
    }
}
